﻿@using System.Linq
@model CloudStorageLight.Core.Web.BlobConfigurationItem
@{
    ViewBag.Title = "Configuration";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div style="margin:50px;">
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })

    <div class="container">

        <div class="row">
            <div class="row-same-height">
                <div class="col-md-2">
                    @("Folder Path")
                </div>
                <div class="col-md-5">
                    @Html.HiddenFor(m => m.BlobType)
                    @Html.HiddenFor(m => m.CurrentPath)
                    @if (Model.Command != "New")
                    {
                        @Html.TextBoxFor(m => m.Path, new { @class = "form-control folderpath", @readonly = "readonly" })
                    }
                    else
                    {
                        @Html.TextBoxFor(m => m.Path, new { @class = "form-control folderpath" })
                    }
                    @Html.ValidationMessageFor(m => m.Path, "", new { @class = "text-danger" })
                </div>
            </div>
        </div>

        @if (Model.BlobType == "AzureBlob")
        {
            <div class="row">
                <div class="row-same-height">
                    <div class="col-md-2">
                        @("Connection String")
                    </div>
                    <div class="col-md-5">
                        @Html.PasswordFor(m => m.ConnectionString, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.ConnectionString, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>
                <div class="row">
                    <div class="row-same-height">
                        <div class="col-md-2">
                            @("BlobContainer Name")
                        </div>
                        <div class="col-md-5">
                            @Html.TextBoxFor(m => m.BlobContainerName, new { @class = "form-control" })
                            @Html.ValidationMessageFor(m => m.BlobContainerName, "", new { @class = "text-danger" })
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="row-same-height">
                        <div class="col-md-2">
                            @("Encrypt Key")
                        </div>
                        <div class="col-md-5">
                            @Html.PasswordFor(m => m.EncryptKey, new { @class = "form-control" })
                            @Html.ValidationMessageFor(m => m.EncryptKey, "", new { @class = "text-danger" })
                        </div>
                    </div>
                </div>
        }
        @if (Model.BlobType == "SharePointDocLib")
        {
            <div class="row">
                <div class="row-same-height">
                    <div class="col-md-2">
                        @("SharePoint Site Url")
                    </div>
                    <div class="col-md-5">
                        @Html.TextBoxFor(m => m.SpSiteUrl, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.SpSiteUrl, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>
                <div class="row">
                    <div class="row-same-height">
                        <div class="col-md-2">
                            @("Document Library")
                        </div>
                        <div class="col-md-5">
                            @Html.TextBoxFor(m => m.DocumentLibraryName, new { @class = "form-control" })
                            @Html.ValidationMessageFor(m => m.DocumentLibraryName, "", new { @class = "text-danger" })
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="row-same-height">
                        <div class="col-md-2">
                            @("User")
                        </div>
                        <div class="col-md-5">
                            @Html.TextBoxFor(m => m.User, new { @class = "form-control" })
                            @Html.ValidationMessageFor(m => m.User, "", new { @class = "text-danger" })
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="row-same-height">
                        <div class="col-md-2">
                            @(CloudStorageLight.Core.Web.ViewMessages.MsgPassword)
                        </div>
                        <div class="col-md-5">
                            @Html.PasswordFor(m => m.Password, new { @class = "form-control" })
                            @Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })
                        </div>
                    </div>
                </div>
        }
        @if (Model.BlobType == "AttachedSharePoint")
        {
            <div class="row">
                <div class="row-same-height">
                    <div class="col-md-2">
                        @("SharePoint Site Url")
                    </div>
                    <div class="col-md-5">
                        @Html.TextBoxFor(m => m.SpSiteUrl, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.SpSiteUrl, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>
                <div class="row">
                    <div class="row-same-height">
                        <div class="col-md-2">
                            @("Document Library")
                        </div>
                        <div class="col-md-5">
                            @Html.TextBoxFor(m => m.DocumentLibraryName, new { @class = "form-control auto-complete" })
                            @*@Html.DropDownListFor(m => m.DocumentLibraryName, (List<SelectListItem>)ViewData["documentList"], new { @class = "form-control" })*@
                            @Html.ValidationMessageFor(m => m.DocumentLibraryName, "", new { @class = "text-danger" })
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="row-same-height">
                        <div class="col-md-2">
                            @("User")
                        </div>
                        <div class="col-md-5">
                            @Html.TextBoxFor(m => m.User, new { @class = "form-control" })
                            @Html.ValidationMessageFor(m => m.User, "", new { @class = "text-danger" })
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="row-same-height">
                        <div class="col-md-2">
                            @(CloudStorageLight.Core.Web.ViewMessages.MsgPassword)
                        </div>
                        <div class="col-md-5">
                            @Html.PasswordFor(m => m.Password, new { @class = "form-control" })
                            @Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })
                        </div>
                    </div>
                </div>

        }
        @if (Model.BlobType == "FTP")
        {
            <div class="row">
                <div class="row-same-height">
                    <div class="col-md-2">
                        @("Server Name")
                    </div>
                    <div class="col-md-5">
                        @Html.TextBoxFor(m => m.FtpUrl, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.FtpUrl, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>
                <div class="row">
                    <div class="row-same-height">
                        <div class="col-md-2">
                            @("Server Folder")
                        </div>
                        <div class="col-md-5">
                            @Html.TextBoxFor(m => m.FtpFolderPath, new { @class = "form-control" })
                            @Html.ValidationMessageFor(m => m.FtpFolderPath, "", new { @class = "text-danger" })
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="row-same-height">
                        <div class="col-md-2">
                            @("FTPS")
                        </div>
                        <div class="col-md-5">
                            @Html.CheckBoxFor(m => m.Ftps)
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="row-same-height">
                        <div class="col-md-2">
                            @("User")
                        </div>
                        <div class="col-md-5">
                            @Html.TextBoxFor(m => m.User, new { @class = "form-control" })
                            @Html.ValidationMessageFor(m => m.User, "", new { @class = "text-danger" })

                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="row-same-height">
                        <div class="col-md-2">
                            @(CloudStorageLight.Core.Web.ViewMessages.MsgPassword)
                        </div>
                        <div class="col-md-5">
                            @Html.PasswordFor(m => m.Password, new { @class = "form-control" })
                            @Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })

                        </div>
                    </div>
                </div>
        }
        @if (Model.BlobType == "DropBox")
        {
            <div class="row">
                <div class="row-same-height">
                    <div class="col-md-2">
                        @("DropBox Folder")
                    </div>
                    <div class="col-md-5">
                        @Html.TextBoxFor(m => m.StorageFolderPath, new { @class = "form-control folder" })
                        @Html.ValidationMessageFor(m => m.StorageFolderPath, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>
        }
        @if (Model.BlobType == "OneDrive")
        {
            <div class="row">
                <div class="row-same-height">
                    <div class="col-md-2">
                        @("OneDrive Folder")
                    </div>
                    <div class="col-md-5">
                        @Html.TextBoxFor(m => m.StorageFolderPath, new { @class = "form-control folder" })
                        @Html.ValidationMessageFor(m => m.StorageFolderPath, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>
        }
        @if (Model.BlobType == "GoogleDrive")
        {
            <div class="row">
                <div class="row-same-height">
                    <div class="col-md-2">
                        @("Google Folder")
                    </div>
                    <div class="col-md-5">
                        @Html.TextBoxFor(m => m.StorageFolderPath, new { @class = "form-control folder" })
                        @Html.ValidationMessageFor(m => m.StorageFolderPath, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>
        }
                <div class="row">
                    <div class="row-same-height">
                        <div class="col-md-2">
                            @("Timezone")
                        </div>
                        <div class="col-md-5">
                            @Html.DropDownListFor(m => m.Timezone, Model.TimezoneList, new { @class = "form-control folderpath" })
                        </div>
                    </div>
                </div>
        <input type="submit" name="submitButton" value="@(CloudStorageLight.Core.Web.ViewMessages.MsgRegister)" class="btn btn-default" />
        @if (Model.Command != "New")
        {
            <input type="submit" name="submitButton" value="@(CloudStorageLight.Core.Web.ViewMessages.CmdRemove)" class="btn btn-default" />
        }

    </div>

}

</div>
@section scripts{
<script type="text/javascript">
    $(function () {
        $('.auto-complete').autocomplete({
            source: '@Url.Action("SharePointListItem")' + "?SpSiteUrl=" + $("#SpSiteUrl").val(),
            minLength: 0,
            delay: 0
        });
        $("#SpSiteUrl").change(function () {
            $('.auto-complete').autocomplete({
                source: '@Url.Action("SharePointListItem")' + "?SpSiteUrl=" + $("#SpSiteUrl").val(),
            });
        });
    });
</script>

}